package com.mapfinal.server.web;

import com.jfinal.core.Controller;
import com.lambkit.common.LambkitResult;

public class WebResult extends LambkitResult {

	public WebResult(WebResultConsts webResultConsts, Object data) {
		super(webResultConsts.getCode(), webResultConsts.getMessage(), data);
	}

	public WebResult(WebResultConsts webResultConsts, String message, Object data) {
		super(webResultConsts.getCode(), message, data);
	}

	public WebResult(int code, String message, Object data) {
		super(code, message, data);
	}
	
	public static WebResult json(WebResultConsts webResultConsts) {
		return new WebResult(webResultConsts, null);
	}

	public static WebResult json(WebResultConsts webResultConsts, Object data) {
		return new WebResult(webResultConsts, data);
	}

	public static WebResult json(WebResultConsts webResultConsts, String message, Object data) {
		return new WebResult(webResultConsts, message, data);
	}

	public static WebResult json(int code, String message, Object data) {
		return new WebResult(code, message, data);
	}

	public static void render(Controller c, WebResultConsts webResultConsts, String message, Object data) {
		c.renderJson(new WebResult(webResultConsts, message, data));
	}

	public static void render(Controller c, int code, String message, Object data) {
		c.renderJson(new WebResult(code, message, data));
	}

	public static void render(Controller c, WebResultConsts webResultConsts, Object data) {
		c.renderJson(new WebResult(webResultConsts, data));
	}

	public static void render(Controller c, WebResultConsts webResultConsts) {
		c.renderJson(new WebResult(webResultConsts, null));
	}

}
